<?php
class Tourtype_model extends Model {

    function Tourtype_model()
    {
        // Call the Model constructor
        parent::Model();
    }
    
	function get_all_tourtypes()
	{
		$query = $this->db->get('tourtypes');
		
		return $query->result_array();
	}
	
    function add_tourtype()
    {
        $data = array(
	               	'tour_name' => $_POST['tour_name'],
					'tour_code' => $_POST['tour_code'],
					'tour_nights' => $_POST['tour_nights']
		            );

		$this->db->insert('tourtypes', $data);
		
		return $this->db->insert_id();
    }
	
	function get_tourtype($id)
	{
		$query = $this->db->get_where('tourtypes', array('id' => $id), 1);
		
		$tour = $query->result_array();
		
		return $tour[0];
	}
	
	function update($id)
	{
		$data = array(
	               	'tour_name' => $_POST['tour_name'],
					'tour_code' => $_POST['tour_code'],
					'tour_nights' => $_POST['tour_nights'],
					'default_price' => $_POST['default_price']
		            );
		
		$this->db->where('id', $id);
		$this->db->update('tourtypes', $data);
		
		return true;
	}
	
	

}
?>